import { createApp } from 'vue'
import dialog from './dialog.vue'

const createDialog = (message, option = {}) => {
  console.log(message, option );
    const mountNode = document.createElement('div')
    const Instance = createApp(dialog, {
      show: true,
      message,
      ...option,
      close: () => {
        Instance.unmount(mountNode)
        document.body.removeChild(mountNode)
        if (option.submitClick) {
          option.submitClick()
        }
      },
    })

    document.body.appendChild(mountNode)
    Instance.mount(mountNode)
}

export default createDialog